package com.woniuxy.service.impl;


import com.woniuxy.dao.UserDao;
import com.woniuxy.entity.User;
import com.woniuxy.service.UserService;


import java.util.List;
import java.util.Objects;

public class UserServiceImpl implements UserService {
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public User findOne(int id) {
        System.out.println("这个是一个日志：我记录了id是："+id+"的用户的查询操作！");
        User one = userDao.findOne(id);
        if (Objects.nonNull(one)){
            System.out.println("查询"+id+"用户成功！");
        }else {
            System.out.println("查询"+id+"用户失败！");
        }
        return one;
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public int addOne(User user) {
        return userDao.addOne(user);
    }


    @Override
    public int updateOne(User user) {
        return userDao.updateOne(user);
    }

    @Override
    public int deleteOne(int id) {
        return userDao.deleteOne(id);
    }
}
